<template>
	<view class="container">
		
		<view class="cd-bg">
			<!-- 基本信息 -->
			<view class="cd-title">
				<uni-row>
					<uni-col :span="20">
						<view class="param">基本信息</view>
					</uni-col>
					<!-- <uni-col :span="4">
						<view class="param" v-if="detail.auditSta==1"><uni-tag text="审核中" type="warning"></uni-tag></view>
						<view class="param" v-if="detail.chengbanSta==1"><uni-tag text="承办中" type="primary"></uni-tag></view>
						<view class="param" v-if="detail.sta>0"><uni-tag text="已完结" type="default"></uni-tag></view>
					</uni-col> -->
				</uni-row>
			</view>
			<view class="cd-body">
				<view class="param"><b>申请人：</b>{{detail.shenqingname}}</view>
				<view class="param"><b>发起时间：</b>{{getFormatedTimeStr(detail.createTime)}}</view>
			</view>
			
			<!-- 特殊参数 -->
			<view class="cd-line">
				<view class="param">通知内容</view>
			</view>
			<view class="cd-body">
				<view class="param"><b>会议主题：</b>{{detail.topic}}</view>
				<view class="param"><b>会议内容：</b>{{detail.content}}</view>
				<view class="param"><b>会议日期：</b>{{getFormatedTimeStr(detail.meetingDate,'MM月DD日')}}</view>
				<view class="param"><b>开始时间：</b>{{detail.startTime}}</view>
				<view class="param"><b>结束时间：</b>{{detail.endTime}}</view>
				<view class="param"><b>地点：</b>{{detail.place}}</view>
				<view class="param"><b>主持：</b>{{detail.host}}</view>
				<view class="param"><b>形式：</b>{{detail.xingshi}}</view>
			</view>
			
			<!-- 相关附件 -->
			<view class="cd-line">
				<view class="param"><b>相关附件</b></view>
			</view>
			<view class="cd-body">
				<!-- 附件 -->
				<view class="param"><b>附件：</b></view>
				<view v-for="(it,idx) in detail.attaches" :key="idx">
				<text style="font-size: 16px;color: #51bb88;" @click="clickAttach(it)">{{ it.name }}</text>
				<br>
				<uni-link style="color:purple;font-size: 15px;" :href="escapePath(it.path)" text="下载"></uni-link>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { websock } from '../../net/websock'
import moment from 'moment'
	export default {
		data() {
			return {
				id: 0,
				taskid: 0,
				see: 0,
				detail: {}
			}
		},
		async onLoad(params) {
			this.id = params.id
			this.taskid = params.taskid
			this.see = params.see
			console.log('onload', params)
			this.getInfo()
		},
		methods: {
			async getInfo() {
				this.detail= await websock.huiyiTongzhiDetail({id: this.id})

				websock.getUserInfoByUid({uid: this.detail.uid}).then(res => {
					this.detail.shenqingname = res.name
				})

				for (let key in this.detail.auditors) {
					websock.getUserInfoByUid({uid: this.detail.auditors[key].uid}).then(res => {
					this.detail.auditors[key].name = res.name
					this.detail.auditors[key].signimg = res.signimg
					})
				}
			},
			
			// 获取格式化时间字符串
			getFormatedTimeStr(stamp, str='MM-DD HH:mm:ss') {
				return moment(stamp).format(str)
			},
			
			//点击放大U图片
			showBigImg(imgurl,cur){
				uni.previewImage({
					current:cur,
					loop:true,
					urls:imgurl,
				})
			},
			async clickAttach(item) {
				let last4 = item.path.substring(item.path.length - 4)
				if (last4 == '.pdf') {
					console.log('pdf')
					uni.navigateTo({ url: `/pages/pdf-view?url=${item.path}` })
				} else {
					// #ifdef APP-PLUS
					plus.runtime.openURL(encodeURI(item.path))
					// #endif
				}
			},
			escapePath(path) {
				return encodeURI(path)
			}
		}
	}
</script>

<style>
@import url("../common/detail.css");
</style>
